def bubble_sort(nums, reverse=False):
    for i in range(len(nums) - 1):
        for j in range(len(nums) - i - 1):
            if nums[j] > nums[j + 1]:
                nums[j], nums[j + 1] = nums[j + 1], nums[j]
    if reverse:
        return nums[::-1]
    else:
        return nums


if __name__ == '__main__':
    print(bubble_sort([1, 2, 3, 4, 5, 10, 7, 8, 9, 6], reverse=True))
    print(bubble_sort([3, 6, 3, 8, 1, 6, 3, 9, 4]))
    print(bubble_sort([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))
